GtkNotebook: Use gdouble in coordinate calculations
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 7 Dec 2015 15:32:15 +0000 (16:32 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 7 Dec 2015 16:40:01 +0000 (17:40 +0100)
Otherwise rounding errors fool the "tab under coordinates" checks on
crossing events, which will be triggered close enough to the window
rectangle if the pointer moves slowly enough.

With this, the tab_prelight() function correctly figures out we've
moved the pointer outside the tab area when called in
gtk_notebook_leave_notify().

https://bugzilla.gnome.org/show_bug.cgi?id=759091

gtk/gtknotebook.c

index 6871074fea859d56a82bc8b2df4e60f582b5a877..91af61ba37ba97e17653677d474b6a4088c111fe 100644 (file)
@@ -2873,8 +2873,8 @@ gtk_notebook_arrow_button_press (GtkNotebook      *notebook,
 static gboolean
 get_widget_coordinates (GtkWidget *widget,
                         GdkEvent  *event,
-                        gint      *x,
-                        gint      *y)
+                        gdouble   *x,
+                        gdouble   *y)
 {
   GdkWindow *window = ((GdkEventAny *)event)->window;
   gdouble tx, ty;
@@ -2905,7 +2905,9 @@ get_widget_coordinates (GtkWidget *widget,
 }
 
 static GList*
-get_tab_at_pos (GtkNotebook *notebook, gint x, gint y)
+get_tab_at_pos (GtkNotebook *notebook,
+                gdouble      x,
+                gdouble      y)
 {
    GtkNotebookPrivate *priv = notebook->priv;
   GtkNotebookPage *page;
@@ -2939,7 +2941,7 @@ gtk_notebook_button_press (GtkWidget      *widget,
   GtkNotebookPage *page;
   GList *tab;
   GtkNotebookArrow arrow;
-  gint x, y;
+  gdouble x, y;
 
   if (event->type != GDK_BUTTON_PRESS || !priv->children ||
       priv->button)
@@ -3323,7 +3325,7 @@ tab_prelight (GtkNotebook *notebook,
 {
   GtkNotebookPrivate *priv = notebook->priv;
   GList *tab;
-  gint x, y;
+  gdouble x, y;
 
   if (get_widget_coordinates (GTK_WIDGET (notebook), (GdkEvent *)event, &x, &y))
     {
@@ -3354,7 +3356,7 @@ gtk_notebook_leave_notify (GtkWidget        *widget,
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPrivate *priv = notebook->priv;
-  gint x, y;
+  gdouble x, y;
 
   if (get_widget_coordinates (widget, (GdkEvent *)event, &x, &y))
     {